package familycostincome;

import java.util.Scanner;

 class setting{
    public  int readnumber(){
        int n = 0;
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        return n;
    }
    public String readstring(){
        String m = "";
        Scanner scan = new Scanner(System.in);
        m = scan.nextLine();
        return m;
    }

}
public class menu {
    public static void main(String[] args) throws InterruptedException {
        setting set = new setting();
        int balance = 10000;
        String details="";
        details ="本金" +balance;

        Scanner scanner = new Scanner(System.in);
        while (true) {

            System.out.println("--------------家庭收支记账记录---------------");
            System.out.println("     -------->1.收支明细<---------");
            System.out.println("     -------->2.登记收入<---------");
            System.out.println("     -------->3.登记支出<----------");
            System.out.println("     -------->4.退出<-----------");
            System.out.println("     -------->5.请选择1-4!<-----");
            System.out.println("请输入: ");
            int key = 0;
            for (; ; ) {
                key = scanner.nextInt();
                if (key >= 1 && key <= 4) {
                    break;
                } else {

                    System.out.println("请选择1-4!!");

                }
            }

            switch (key) {

                case 2:
                    System.out.println("---------登记收入-----------");
                    System.out.print("本次收入金额：");
                    int amount1 = set.readnumber();
                    System.out.print("收入说明:");
                    String know = set.readstring();
                    balance  += amount1;
                    details += "\n收入" + amount1 + "\n存款" + (balance);
                    System.out.println(details);

                    System.out.println("---------登记完成-----------");
                    break;
                case 3:
                    System.out.println("---------登记支出-----------");
                    System.out.print("本次支出金额：");
                    int amount2 = set.readnumber();
                    System.out.print("支出说明:");
                    String know2 = set.readstring();
                    balance -= amount2;
                    details += "支出" + amount2 + "\n存款" + (balance);
                    System.out.println( details);

                    System.out.println("---------登记完成-----------");
                    break;
                case 1://收支明细
                    System.out.println("---------收账记录明细----------");
                    System.out.println(details);

                    break;
                case 4: {
                    System.out.println("退出成功!!!");
                    break;
                }

            }

        }

    }
}